//
//  NKAgeCategroyPopView.m
//  NiKi
//
//  Created by qiang chen on 16/6/21.
//  Copyright © 2016年 qiang chen. All rights reserved.
//

#import "NKAgeCategroyPopView.h"

@interface NKAgeCategroyPopView () {
    UIButton *_selectedBtn;
    __weak IBOutlet UIView *ageBtnBgV;
}

@end
@implementation NKAgeCategroyPopView

- (void)awakeFromNib {
    for (UIView *view in ageBtnBgV.subviews) {
        if ([view isKindOfClass:[UIButton class]]) {
            view.layer.borderColor = [UIColor colorWithHex:0xff61D4E6].CGColor;
        }
    }
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    [self.blurV addGestureRecognizer:tapGesture];
}

- (void)tap:(UITapGestureRecognizer *)tapGesture {
    [UIView animateWithDuration:0.25 animations:^{
        self.btnBgV.transform = CGAffineTransformMakeScale(0.1, 0.1);
        self.blurV.hidden = YES;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

- (IBAction)ageBtnClick:(UIButton *)sender {
    if (_selectedBtn != sender) {
        sender.selected = YES;
        [sender setBackgroundColor:MainColor];
        [_selectedBtn setBackgroundColor:[UIColor whiteColor]];
        _selectedBtn.selected = NO;
        _selectedBtn = sender;
    }
    
    [self tap:nil];
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(ageCategroyPopView:ageBtnClick:)]) {
        [self.delegate ageCategroyPopView:self ageBtnClick:sender];
    }
}

@end
